package com.elektronikforumet.camalert;

import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ListView;

import com.elektronikforumet.camalert.FolderAdapter.OnFileSelectedListener;

public class SelectFileActivity extends Activity implements OnFileSelectedListener {

	public static final String EXTRAS_FILE_FILTER = "fileFilter";
	public static final String EXTRAS_SELECTED_FILE = "selectedFile";
	
	//private String mFileFilter = ""; 
	//private FileFilter mFilter = null;
	private ListView mFileList = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.select_file);
		
		mFileList = (ListView)findViewById(R.id.file_list);
		
		//mFileFilter = getIntent().getStringExtra(EXTRAS_FILE_FILTER);
		
		FolderAdapter fa = new FolderAdapter(getBaseContext(), Environment.getExternalStorageDirectory(), ".mp3");
		
		
		mFileList.setAdapter(fa);
	}

	@Override
	public void onFileSelected(File file) {
		Intent i = new Intent();
		i.putExtra(EXTRAS_SELECTED_FILE, file.getAbsolutePath());
		setResult(RESULT_OK, i);
		finish();		
	}

	
	
	
}
